package com.xinyun.server.protocol.send;

import com.xinyun.server.protocol.ProtocolData;

import java.util.Calendar;
import java.util.Random;

/**
 * Created by bubusy on 16/5/22.
 */
public class SyncTime extends ProtocolData {

    public SyncTime() {
        this.header.setLength(6);
        this.header.setMsgType(5);
        this.header.setB4(0);
        this.header.setB5(0);
        this.header.setB6(0);

        Calendar calendar = Calendar.getInstance();
        int year = calendar.get(Calendar.YEAR) - 2000;//去掉前面两位
        int month = calendar.get(Calendar.MONTH) + 1;
        int day = calendar.get(Calendar.DAY_OF_MONTH);

        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        int minute = calendar.get(Calendar.MINUTE);
        int second = calendar.get(Calendar.SECOND);

        this.bodyBytes.writeByte(year);
        this.bodyBytes.writeByte(month);
        this.bodyBytes.writeByte(day);
        this.bodyBytes.writeByte(hour);
        this.bodyBytes.writeByte(minute);
        this.bodyBytes.writeByte(second);


    }

}
